struct Solution {}

fn main() {}

impl Solution {
    pub fn count_good_triplets(arr: Vec<i32>, a: i32, b: i32, c: i32) -> i32 {
        let abc: Vec<i32> = vec![a, b, c];
        let mut res = 0;
        for idx_i in 0..arr.len() {
            for idx_j in idx_i + 1..arr.len() {
                for idx_k in idx_j + 1..arr.len() {
                    if Self::check(&arr[idx_i], &arr[idx_j], &arr[idx_k], &abc) {
                        res += 1;
                    }
                }
            }
        }
        res
    }

    fn check(i: &i32, j: &i32, k: &i32, abc: &Vec<i32>) -> bool {
        let condition1 = (i - j).abs() <= abc[0];
        let condition2 = (j - k).abs() <= abc[1];
        let condition3 = (i - k).abs() <= abc[2];
        condition1 && condition2 && condition3
    }
}